<template>
    <div>
                <div class="count-down" :style="{backgroundImage:`url(${url})`}">
                    <span class="jump" @click="go" style="cursor: pointer">倒计时{{num}}</span>
                </div>
    </div>
</template>

<script>
    import  imggo from "../assets/dom.jpg"
    export default {
        name: "countDown",
        data(){
            return {
                url:imggo,
                timer:null,
                num:5
            };
        },
        methods:{
            go(){
                clearInterval(this.timer);
                this.$router.push("/myapp/home")
            },

            // 开屏广告
            play(){
                this.timer=setInterval( ()=>{
                    this.num--;
                    if(this.num==0){
                        clearInterval(this.timer);
                        this.$router.push("/myapp/home")
                    }
                },1000)
            },
        },
        created(){
            // this.$axios.get(`https://api.uomg.com/api/rand.img3`).then(res=>{
            //     console.log(res.config.url);
            //     this.url=res.config.url;
            // })
        },
        mounted() {
            this.play();
        }
    }
</script>

<style scoped>
    .count-down{
        position: fixed;
        width:100%;
        height:100vh;
        padding:20px;
        background-size: cover;
        background-position: center;
        z-index:999;
    }
    .jump{
        /*float:right;*/
        padding:4px 10px ;
        border:2px solid black;
        border-radius:12px ;

    }
</style>